package test.libvirt;

import org.libvirt.*;


public class Connection {

	// Use this to flag errors in the test run.
    public static String FIXME = "\n<=====================================>\n<============== FIXME ================> ";

	
	public static void main(String[] args) {
		
		Connect conn = null;
        ConnectAuth defaultAuth = new ConnectAuthDefault();
        
        try{ 
        	conn = new Connect("xen+ssh://root@192.168.74.16", defaultAuth,0);
        	System.out.println("Encrypted connection successful!"); 
        } catch (LibvirtException e){ 
        	System.out.println("exception caught:"+e);
        	System.out.println(e.getError()); 
        }
        
        try {
            // Check nodeinfo
            NodeInfo nodeInfo = conn.nodeInfo();
            System.out.println("virNodeInfo.model:" + nodeInfo.model);
            System.out.println("virNodeInfo.memory:" + nodeInfo.memory);
            System.out.println("virNodeInfo.cpus:" + nodeInfo.cpus);
            System.out.println("virNodeInfo.nodes:" + nodeInfo.nodes);
            System.out.println("virNodeInfo.sockets:" + nodeInfo.sockets);
            System.out.println("virNodeInfo.cores:" + nodeInfo.cores);
            System.out.println("virNodeInfo.threads:" + nodeInfo.threads);

            // Exercise the information getter methods
            System.out.println("getHostName:" + conn.getHostName());
            System.out.println("getCapabilities:" + conn.getCapabilities());
            System.out.println("getMaxVcpus:" + conn.getMaxVcpus("xen"));
            System.out.println("getType:" + conn.getType());
            System.out.println("getURI:" + conn.getURI());
            System.out.println("getVersion:" + conn.getVersion());
            System.out.println("getLibVirVersion:" + conn.getLibVirVersion());
            
        } catch (LibvirtException e) {
            System.out.println(FIXME);
            System.out.println("exception caught:" + e);
            System.out.println(e.getError());
        }
	}
	
	
	

}
